<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()	+ path + "/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>">
		<title><s:text name="sys.app_title" /></title>
		<%@include file="../include/contentheader.jsp"%>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/app.js"></script>
		<link rel="stylesheet" type="text/css" href="css/main.css" />
		<link rel="stylesheet" type="text/css" href="css/dtree.css" />
		<script type="text/javascript" src="js/dtree.js"></script>
		<script type="text/javascript" src="dwr/engine.js"></script>
		<script type="text/javascript" src="dwr/util.js"></script>
		<script type="text/javascript" src="dwr/interface/departmentDwrJs.js"></script>
		<script type="text/javascript" src="js/dep.js"></script>
		<link rel="stylesheet" href="css/dep.css" type="text/css" />
		<script type="text/javascript">
			function doSelect(did,dname){
				if(did != undefined && dname != undefined){
					window.returnValue = did+','+dname;
				}else{
					window.returnValue = '';
				}
			}
			function doOk(){
				if(window.returnValue == undefined){
					window.returnValue = '';
				}
				window.close();
			}
			function doCancel(){
				window.returnValue = '';
				window.close();
			}
		</script>
	</head>
	<body onload="buildTree();" style="padding-top:5px;">
		<div class="mainContainer">
			<div class="headerTitle">请选择上级部门</div>
			<div><input type="button" onclick="doOk();" value="确定" /><input type="button" onclick="doCancel();" value="取消" /></div>
			<div id="myTree" style="width:100%;height:400px;overflow-y:auto;color:#333333;border:1px solid #C0C0C0;border-right:0px;border-bottom:0px;">
			<script type="text/javascript">
				dtree = new dTree('dtree');
				dtree.clearCookie();
				function buildTree(){
					departmentDwrJs.getAllDepartment(function(departmentList) {
					    dtree.add(0, -1, '广元电业局', "javascript:doSelect(\'000\',\'广元电业局\')");
						for(var i=0; i<departmentList.length; i++){
							for(var j=0; j<departmentList.length; j++){
				    			if(departmentList[i].depid==departmentList[j].depparentid && departmentList[j].depstatus=='A'){
				    				dtree.add(departmentList[j].depid,departmentList[j].depparentid,departmentList[j].depname,"javascript:doSelect(\'"+departmentList[j].depid+"\',\'"+departmentList[j].depname+"\')");
								}
				    		}
						}
						showBuildTree(dtree.toString());
					});
				}
				function showBuildTree(treeStr) {
					document.getElementById("myTree").innerHTML = treeStr;
				}
			</script>
			</div>
		</div>
	</body>
</html>